package cn.trda.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.trda.mapper.AsAccountMapper;
import cn.trda.mapper.AsAccountdetailMapper;
import cn.trda.pojo.Account;
import cn.trda.pojo.Accountdetail;
import cn.trda.service.AccountService;
@Service
public class AccountServiceImpl implements AccountService {

	@Autowired
	private AsAccountMapper asAccountMapper;
	@Autowired
	private AsAccountdetailMapper asAccountdetailMapper;

	@Override
	public int insertSelective(Account account,Accountdetail accountdetail) {
		// TODO Auto-generated method stub
		account.setMoney(account.getMoney()+accountdetail.getMoney());
		account.setMoneybak(account.getMoneybak()+accountdetail.getMoney());
		accountdetail.setAccountmoney(account.getMoney());	
		return asAccountdetailMapper.insertSelective(accountdetail);
	}

	@Override
	public Account selectByUserId(Long id) {
		// TODO Auto-generated method stub
		
		return asAccountMapper.selectByUserId(id);
	}

	@Override
	public Account getAccountByUserId(Long agentid) {
		// TODO Auto-generated method stub
		return asAccountMapper.getAccountByUserId(agentid);
	}

}
